import request from '@/utils/request'

export async function login(data) {
  return request({
    url: '/login',
    method: 'post',
    data,
  })
}

export async function socialLogin(data) {
  return request({
    url: '/socialLogin',
    method: 'post',
    data,
  })
}

export function getUserInfo() {
  //此处为了兼容mock.js使用data传递accessToken，如果使用mock可以走headers
  return request({
    url: '/user/userInfo',
    method: 'post',
    data: {},
  })
}

export function logout() {
  return request({
    url: '/logout',
    method: 'post',
  })
}

export function register() {
  return request({
    url: '/register',
    method: 'post',
  })
}

export function getList(params) {
  return request({
    url: '/user/getList',
    method: 'get',
    params,
  })
}

export function get(params) {
  return request({
    url: '/user/get',
    method: 'get',
    params,
  })
}

export function _delete(params) {
  return request({
    url: '/user/delete',
    method: 'post',
    data: params,
  })
}

export function update(params) {
  return request({
    url: '/user/update',
    method: 'post',
    data: params,
  })
}

export function add(params) {
  return request({
    url: '/user/add',
    method: 'post',
    data: params,
  })
}

export function updatePassword(params) {
  return request({
    url: '/user/updatePassword',
    method: 'post',
    data: params,
  })
}
